# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=giflib

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=5.1.0
pkgrel=1
pkgdesc="A library for reading and writing gif images (mingw-w64)"
arch=('any')
url="http://sourceforge.net/projects/giflib"
license=("MIT")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "xmlto")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
options=('staticlibs' 'strip')
source=("http://downloads.sourceforge.net/sourceforge/giflib/${_realname}-${pkgver}.tar.bz2"
        "giflib-5.0.4-include-stddef.patch")
md5sums=('c7e9f1c10b755ab955156d4c1ac7fc5d'
         'e39b98822334f2bd2009469e5dea65c5')

prepare() {
  cd "$srcdir/giflib-$pkgver"
  patch -Np1 -i "$srcdir/giflib-5.0.4-include-stddef.patch"
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  "${srcdir}"/${_realname}-${pkgver}/configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX}
  make bin_PROGRAMS=''
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" bin_PROGRAMS='' install
}
